#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << gcd(a, b);
	return 0;
}